﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CE.Job;

public partial class HR_job_preview : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["JobTitle"] == null)
            {
                if (Request.Params["jid"] != null)
                {
                    int _jobid = int.Parse(Request.Params["jid"].ToString());
                    Job _job = new Job();
                    JobDB _jobdb = new JobDB();
                    _job = _jobdb.GetJobByID(_jobid);
                    if (_job != null)
                    {
                        lblJobTitle.Text = _job.JobTitle;
                        lblJobDescription.Text = _job.JobDescription;
                        lblResponsibilities.Text = _job.Responsibilities;
                        lblRequirements.Text = _job.Requirements;
                        lblEndDate.Text = _job.EndDate.ToString("dd/MM/yyyy");
                        lblCreatedDate.Text = DateTime.Now.ToString("dd MMM yyyy");
                        lblStartDate.Text = _job.StartDate.ToString("dd/MM/yyyy");

                        if (!this.DesignMode)
                        {
                            Page.Title = _job.JobTitle;

                            // Render: <meta name="keywords" content="Some words listed here" />
                            System.Web.UI.HtmlControls.HtmlMeta meta = new System.Web.UI.HtmlControls.HtmlMeta();
                            meta.Name = "keywords";
                            meta.Content = "Some words listed here";
                            this.Header.Controls.Add(meta);
                        }
                    }

                    string _country = _job.Country;
                    switch (_country)
                    {
                        case "HK":
                            aHK.Attributes.Add("class", "select");
                            break;
                        case "ID":
                            aID.Attributes.Add("class", "select");
                            break;
                        case "MY":
                            aMY.Attributes.Add("class", "select");
                            break;
                        case "SG":
                            aSG.Attributes.Add("class", "select");
                            break;
                        case "TH":
                            aTH.Attributes.Add("class", "select");
                            break;
                    }
                }
            }
            else
            {
                lblJobTitle.Text = Session["JobTitle"].ToString();
                lblJobDescription.Text = Session["JobDescription"].ToString();
                lblResponsibilities.Text = Session["Responsibilities"].ToString();
                lblRequirements.Text = Session["Requirements"].ToString();
                lblCreatedDate.Text = DateTime.Now.ToString("dd MMM yyyy");
                lblEndDate.Text = Session["EndDate"].ToString();
                lblStartDate.Text = Session["StartDate"].ToString();

                if (!this.DesignMode)
                {
                    Page.Title = Session["JobTitle"].ToString();

                    // Render: <meta name="keywords" content="Some words listed here" />
                    System.Web.UI.HtmlControls.HtmlMeta meta = new System.Web.UI.HtmlControls.HtmlMeta();
                    meta.Name = "keywords";
                    meta.Content = "Some words listed here";
                    this.Header.Controls.Add(meta);
                }
            }
        }
    }
}
